#pragma once

#include "Definitions.h"

class Message
{
protected:
	static const char stop = DELIMITER;
protected:
	int messageType;
	char temp[MESSAGE_BUFF_LEN];
public:
	//virtual void pack(char* buffer)=0;
	//virtual void unPack(char* dataBuffer)=0;
protected:
	int ParseString(int start, char* buffer, char* const & data, char const & stop)
	{
		char cursor = data[start];
		if(cursor == stop)
		{
			buffer[0] = '\0';
			return 1;
		}
		int i=0;

		//weirdest for loop evar!!
		for(start; cursor != stop; start++, ++i)
		{
			cursor = data[start];
			buffer[i] = cursor;
		}
		buffer[i-1] = '\0';

		return i;
	}
	BOOL_STORAGE StringToBoolStorageType(char* buffer)
	{
		BOOL_STORAGE value = 0;
		for (buffer; *buffer; buffer++)
			value = 10*value + (*buffer - '0');
		return value;
	}
};